import 'package:flutter/material.dart';

class UnderlineWithTitle extends StatelessWidget {
  UnderlineWithTitle({Key key, this.title}) : super(key: key);
  final String title;

  @override
  Widget build(BuildContext context) {
    return Column(children: [
      Stack(
        alignment: Alignment.center, //指定未定位或部分定位widget的对齐方式
        children: <Widget>[
          Container(
            color: Colors.blue,
            height: 1,
            margin: EdgeInsets.all(20),
          ),
          Positioned(
              child: Container(
                  padding: EdgeInsets.all(10.0),
                  color: Colors.white,
                  child: Text(this.title,
                      style: TextStyle(
                          fontSize: 16,
                          background: Paint()
                            ..color = Color.fromRGBO(255, 255, 255, 1),
                          color: Color.fromRGBO(0, 0, 0, 1))))),
        ],
      ),
    ]);
  }
}
